package com.gxa.meiye.portal.service.zy.impl;

import com.gxa.meiye.core.utils.RestUtils;
import com.gxa.meiye.portal.service.zy.LocationService;

import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.Map;

/**
 * @Author: zy
 * @CreateTime: 2022-07-21  17:17
 */
@Service
public class LocationServiceImpl implements LocationService {
//    @Autowired
//    @Qualifier("myJmsTemplate")
//    private JmsMessagingTemplate jmsMessagingTemplate=null;
    @Override
    public void add(String phone,String img,String nickName) {
        String url="http://1.117.60.194:8080/user/add";
        MultiValueMap<String,Object> params=new LinkedMultiValueMap<>();
        params.add("phone",phone);
        params.add("img",img);
        params.add("nickName",nickName);
        //jmsMessagingTemplate.convertAndSend("cacheLocation",map);
        RestUtils restUtils=new RestUtils();
        restUtils.postWithParams(url, params);

    }

    @Override
    public Map select(String phone) {
        String url="http://1.117.60.194:8080/user/select";
        MultiValueMap<String,Object> params=new LinkedMultiValueMap<>();
        params.add("phone",phone);
        RestUtils restUtils=new RestUtils();

        Map map = restUtils.postWithParams(url, params);
        Object code = map.get("code");
        System.out.println(code);
        Map<String,String> data=null;
        if (code.equals("1")) {
          data = (Map) map.get("data");
        }
        System.out.println(data);
        return data;
    }
}
